package classLoader;

public class LoaderSample1 {
	public static void main(String[] args) {
		Class c;
		ClassLoader cl;
		cl = ClassLoader.getSystemClassLoader();
		// 系统类装载器实例化自类sun.misc.Launcher$AppClassLoader
		System.out.println(cl);
		cl = cl.getParent();
		// 系统类装载器的parent实例化自类sun.misc.Launcher$ExtClassLoader
		System.out.println(cl);
		cl = cl.getParent();
		// 系统类装载器parent的parent为bootstrap
		System.out.println(cl);
		try {
			c = Class.forName("java.lang.Object");
			cl = c.getClassLoader();
			// 核心类java.lang.Object是由bootstrap装载的
			System.out.println("java.lang.Object's loader is " + cl);
			c = Class.forName("classLoader.LoaderSample1");
			cl = c.getClassLoader();
			// 用户类LoaderSample1是由系统类装载器装载的
			System.out.println("LoaderSample1's loader is " + cl);
			

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
